package JVM;

public class itrruptTest {
    public static class myThread extends Thread{
        @Override
        public void run() {
            System.out.println("Running");
            while (true){
                    try {
                        //Thread.sleep(5000);  在sleep的时候被打断的话，isInterrupted返回的是false
                        if (this.isInterrupted()){
                            System.out.println("I am interrupted");
                            break;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }finally {
                        System.out.println(this.isInterrupted());
                    }

            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        
        Thread t1=new myThread();
        t1.start();
        Thread.sleep(1000);
        t1.interrupt();

    }
}
